<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
<%  
    String path = request.getContextPath();  
    String basePath = request.getScheme() + "://"  
            + request.getServerName() + ":" + request.getServerPort()  
            + path + "/";  
%>  
  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
<html>  
    <head>  
        <base href="<%=basePath%>">   
        <script type="text/javascript" src="jquery.js">  
</script>  
        <style type="text/css">  
<!--  
body {  
    margin-left: 0px;  
    margin-top: 0px;  
    margin-right: 0px;  
    margin-bottom: 0px;  
    font-size: 14px;  
}  
-->  
</style>  
        <script type="text/javascript">
function aa() {   
    $("#div1").hide();  
    $("#div2").show();
    $.get("hello/bar", function(data, textStatus) {//AJAX方式发送请求到Action的sumPre方法，计算后将百分比data返回来   
    	alert(data);
        $("#img").attr("width", parseInt(data) * 1.5);//设置进度条长度，这里*1.5只是为了把进度条显示长一点，好看一点  
            $("#p").html(parseInt(data) + "%");//进度百分比  
        });  
    window.setTimeout("aa()", 100);//定时执行  
}  
</script>  
    </head>  
  
    <body>  
        <div id="div1">  
            <form name='aform1' method='post' action="fileUpload.action"  
                enctype="multipart/form-data">  
                <input name='file' type='file' />  
                <input type="submit" value="上传" onclick="return aa();" />  
            </form>  
        </div>  
        <div id="div2" style="width: 400px; display: none;">  
            正在上传...  
            <img alt="" src="13221820.gif" width="16" height="16">  
            <img id="img" alt="" src="percent.jpg" width="1" height="5">  
            <span id="p" style="position: absolute; right: 30%; top: 0px;"></span>  
        </div>  
    </body>  
</html> 